import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author fangkun
 * @create 2022-11-10-15:43
 */
public class CollectingResult {
    public static void main(String[] args) {

        Iterator<Integer> iter = Stream.iterate(0, n -> n + 1).limit(10).iterator();
        while (iter.hasNext()){
            System.out.println(iter.next());
        }

        Object[] numbers = Stream.iterate(0, n -> n + 1).limit(10).toArray();
        System.out.println("Object array:" + numbers);

        try {
            Integer number = (Integer) numbers[0];
            System.out.println("number:"+number);
            Integer[] number2 = (Integer[]) numbers;
        }catch (Exception e){
            System.out.println(e);
        }

    }

}
